import { service, crudParamsSerializer } from '@/utils/request'
import { CreateQueryParams } from '@nestjsx/crud-request'
import { Artist } from './artist.dto'

export const defaultArtistData: Partial<Artist> = {
  name: '',
  alternateNames: [],
  gender: null,
  birthday: null,
  description: '',
  images: [],
  visible: false
}

export function getArtists (params: CreateQueryParams) {
  return service.request({
    url: '/resources/artists',
    method: 'get',
    params,
    paramsSerializer: crudParamsSerializer
  })
}

export function getArtistById (id: number | string, params: CreateQueryParams) {
  return service.request({
    url: `/resources/artists/${id}`,
    method: 'get',
    params,
    paramsSerializer: crudParamsSerializer
  })
}

export function checkFollowing (id: number | string) {
  return service.request({
    url: `/resources/artists/${id}/follow`,
    method: 'get'
  })
}

export function follow (id: number | string) {
  return service.request({
    url: `/resources/artists/${id}/follow`,
    method: 'post'
  })
}

export function unfollow (id: number | string) {
  return service.request({
    url: `/resources/artists/${id}/follow`,
    method: 'delete'
  })
}
